package com.colt.usercenter.util.response;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

@Builder
@Data
@AllArgsConstructor
public class BaseResponse<T> {
    /**
     * 响应码
     */
    private int code;
    /**
     * 响应消息
     */
    private String msg;

    private T data;

    protected BaseResponse() {}
    protected BaseResponse(CodeEnum code) {
        this.code = code.getCode();
        this.msg = code.getMsg();
    }
    private BaseResponse(CodeEnum code, T data) {
        this.data = data;
    }
    public static <T> BaseResponse<T> out(CodeEnum code, T data) {
        return new BaseResponse<T>(code, data);
    }
    public static BaseResponse out(CodeEnum code) {
        return new BaseResponse(code);
    }
    public int getCode() {
        return code;
    }
    public void setCode(int code) {
        this.code = code;
    }
    public String getMsg() {
        return msg;
    }
    public void setMsg(String msg) {
        this.msg = msg;
    }
}